#include <linux/init.h>
#include <linux/sched.h>
#include <linux/printk.h>
#include <linux/sched/task.h>
#include <linux/delay.h>
#include <msh/export.h>
#include <linux/ktime.h>

#include <stdlib.h>

static void gktime(int argc, char **argv)
{
    int id = 0;
    ktime_t t;

    if (argc == 2)
    {
        id = atoi(argv[1]);
    }

    switch (id)
    {
    case 0:
    {
        t = ktime_get();

        printk("ktime_get: %lld\n", t);
    }
    break;
    case 1:
    {
        t = ktime_get_real();

        printk("ktime_get_real: %lld\n", t);
    }
    break;
    case 10:
    {
        ktime_t tmp;
        int val;

        for (int i = 0; i < 10; i ++)
        {
            t = ktime_get();
            msleep(1000);
            tmp = ktime_get();
            val = tmp - t;
            printk("interval: %d\n", val);
        }
    }
    break;
    }
}
MSH_CMD_EXPORT(gktime, test get ktime);

static void gjif(int argc, char **argv)
{
    unsigned long val;
    
    val = jiffies;

    printk("jiffies: %lu\n", val);
}
MSH_CMD_EXPORT(gjif, test get jiffies);
